package trouger.dmt;

/**
 * A record group is a set of records having the same key with each other.
 * This interface is used in ReducerEntity. 
 * Logic processing codes should be placed in implementations of the methods of this interface.
 */
public interface RecordGroupFilter {
	/**
	 * Set a {@link RecordOutputer} implementation class instance for this filter,
	 * and then this filter can output records whenever it wants.
	 * This method must be called before calling any other method of this filter object.
	 * @param recordOutputer a {@link RecordOutputer} implementation class instance
	 */
	public void setRecordOutputer(RecordOutputer recordOutputer);
	/**
	 * This method is called to indicate that the following incoming records
	 * are from the [sourceIndex]th source table.
	 * @return true to continue filtering, false to ignore all the following records of this record group,
	 * and no other methods of this object will be called then.
	 * @param sourceIndex are one based.
	 */
	public boolean beginRecordSource(int sourceIndex);
	/**
	 * Process one record from the current source table.
	 * @return true to continue filtering; false to ignore all the following records of this record group,
	 * and no other methods of this object will be called then.
	 * @param record field indices are one-based, that is, record[1] is the first field.
	 */
	public boolean processRecord(String[] record);
	/**
	 * This method is called to indicate that all records of this record group
	 * that are from the current source table, are filtered.
	 * @return true to continue filtering, false to ignore all the following records of this record group,
	 * and no other methods of this object will be called then.
	 */
	public boolean endRecordSource();
	/**
	 * This method is called to indicate that all records of this record group
	 * are filtered.
	 */
	public void endOfGroup();
}
